package com.easytopit.demo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.easytopit.demo.dao.HallMapper;
import com.easytopit.demo.domain.Hall;
import com.easytopit.demo.exception.BizException;
import com.easytopit.demo.service.HallService;

/**
 * @author YWQ
 *
 */
@Service
public class HallServiceImpl implements HallService{
	
	@Autowired
	private HallMapper hallMapper;

	@Override
	public Hall add(String cinemaName, String name, Integer quantity, String seat) throws BizException {
		if (cinemaName == null) throw new BizException("影院名称不能为空"); 
		if (name == null) throw new BizException("影厅名称不能为空"); 
		if (quantity == null) throw new BizException("影厅数量不能为空"); 
		if (seat == null) throw new BizException("影厅座位不能为空"); 
		
		Hall hall = new Hall();
		hall.setCinemaName(cinemaName);
		hall.setName(name);
		hall.setQuantity(quantity);
		hall.setSeat(seat);
		Integer insert = hallMapper.insert(hall);
		if (insert != null) return hall;
		return null;
	}

	@Override
	public Integer update(String cinemaName, String name, Integer quantity, String seat) throws BizException {
		return hallMapper.update(cinemaName, cinemaName, quantity, seat);
	}
}